<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input id="input" value="">
<button onclick="doCrypto()">解密</button>
<div>
        解密内容是 <span id="jiemiedata"></span> 内容长度为<span id="jiemichangdu"></span>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/crypto-js@4.0.0/crypto-js.min.js"></script>
<script>
    var  $iv = 'c242519d86950b94';
    var  $key = "75125dbd26b8d160";
var  msg;
    var key = CryptoJS.enc.Utf8.parse($key);
    var iv =    CryptoJS.enc.Utf8.parse($iv);

    function doCrypto() {
        data = document.querySelector('#input').value;
        if(!data || data.length<1 ){
            alert('出错了');
            return ;
        }
        var decrypted = CryptoJS.AES.decrypt(data, key, {
            iv: iv,
            mode: CryptoJS.mode.CBC, //确保此处为默认值CBC
            padding: CryptoJS.pad.Pkcs7 //确保此处为默认值Pkcs7
        });
        msg = decrypted.toString(CryptoJS.enc.Utf8);
        console.log(msg);
        var msg2=atob(msg.trim());

        document.querySelector('#jiemiedata').textContent=msg2;
        document.querySelector('#jiemichangdu').textContent=msg2.length
    }
</script>
</html>